package com.yu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yu.judge.service.JudgeService;
import com.yu.model.entity.Question;
import com.yu.model.entity.QuestionSubmit;

import com.yu.service.QuestionService;
import com.yu.service.QuestionSubmitService;
import com.yu.mapper.QuestionSubmitMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author 33522
* @description 针对表【question_submit(题目提交)】的数据库操作Service实现
* @createDate 2023-10-25 13:54:00
*/
@Service
public class QuestionSubmitServiceImpl extends ServiceImpl<QuestionSubmitMapper, QuestionSubmit>
    implements QuestionSubmitService{


    @Resource
    private QuestionSubmitMapper questionSubmitMapper;


    @Resource
    private QuestionService questionService;

    @Override
    public QuestionSubmit add(QuestionSubmit questionSubmit) {


        questionSubmit.setQuestionId(1L);
        questionSubmit.setUserId(1L);
        questionSubmit.setLanguage("java");


        Question question = questionService.getById(questionSubmit.getQuestionId());
        if(question!=null){
            questionSubmitMapper.insert(questionSubmit);
            QuestionSubmit questionSubmitJudge = questionSubmitMapper.selectById(questionSubmit.getId());
            return questionSubmitJudge;
        }

        return null;
    }
}




